#include "StdAfx.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include "Constants.h"


CConstants::CConstants(void)
{
	m_constants["INPUT_2D"] = "FALSE";
	m_constants["USE_TEXTURE"] = "FALSE";
	m_constants["TEXTURE_FILE"] = "texture.bmp";
	m_constants["USE_PERSPECTIVE"] = "TRUE";

	Initialize();
}


CConstants::~CConstants(void)
{
}

void CConstants::Initialize()
{
	fstream inputFileStream("rasterizer.cfg", ios_base::in);
	while (!inputFileStream.eof())
	{
		string str;
		getline(inputFileStream, str);

		stringstream ss(str);
		
		string variableName;
		ss >> variableName;
		string temp;
		ss >> temp;
		string value;
		ss >> value;

		SetValue(variableName, value);
	}

	inputFileStream.close();
}

void CConstants::SetValue(const std::string& variable, const std::string& value)
{
	m_constants[variable] = value;
}

std::string CConstants::GetValue(const std::string& variable) const
{
	return m_constants.at(variable);
}

bool CConstants::IsTrue(const std::string& variable) const
{
	return m_constants.at(variable) == "TRUE";
}